from django.contrib import admin
from .models import TestReport, ReportDetail, Dashboard

@admin.register(TestReport)
class TestReportAdmin(admin.ModelAdmin):
    list_display = ('name', 'report_type', 'target_name', 'status', 'pass_rate', 'duration', 'created_by', 'created_at')
    list_filter = ('report_type', 'status', 'created_at')
    search_fields = ('name', 'target_name')
    readonly_fields = ('created_at',)
    date_hierarchy = 'created_at'

@admin.register(ReportDetail)
class ReportDetailAdmin(admin.ModelAdmin):
    list_display = ('case_name', 'report', 'status', 'duration', 'start_time')
    list_filter = ('status', 'case_type')
    search_fields = ('case_name', 'report__name')
    readonly_fields = ('start_time', 'end_time')

@admin.register(Dashboard)
class DashboardAdmin(admin.ModelAdmin):
    list_display = ('date', 'ui_pass_rate', 'api_pass_rate', 'total_tasks', 'executed_tasks')
    readonly_fields = ('created_at', 'updated_at')
    date_hierarchy = 'date'